package com.globaldom.model;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable
public class CivResource implements Serializable {

	@NotPersistent
	private static final long serialVersionUID = 1L;

	
//	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@PrimaryKey
	private String id;

	@Persistent
	private String person;

	// Number of civilians for each resource
	@Persistent
	private Integer CivDeployed;
	// availability of resource
	@Persistent
	private Long ResAvailable;
	// kind of resource
	@Persistent
	private Integer ResType;
	// last update of resource. increment each hour
	@Persistent
	private Date resourceUpdated = new Date();

	@NotPersistent
	public static final transient Integer FOOD = 0;
	@NotPersistent
	public static final transient Integer WATER = 1;
	@NotPersistent
	public static final transient Integer OIL = 2;
	@NotPersistent
	public final static transient Integer WOOD = 3;
	@NotPersistent
	public static final transient Integer SILVER = 4;
	@NotPersistent
	public static final transient Integer GOLD = 5;
	@NotPersistent
	public static final transient Integer DOLLAR = 6;
	@NotPersistent
	public static final transient Integer XP = 7;
	@NotPersistent
	public static final transient Integer KARMA = 8;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getPerson() {
		return person;
	}

	public void setPerson(String person) {
		this.person = person;
	}

	public Integer getCivDeployed() {
		return this.CivDeployed;
	}

	public void setCivDeployed(Integer CivDeployed) {
		this.CivDeployed = CivDeployed;
	}

	public Long getResAvailable() {
		return this.ResAvailable;
	}

	public void setResAvailable(Long ResAvailable) {
		this.ResAvailable = ResAvailable;
	}

	public Integer getResType() {
		return this.ResType;
	}

	public void setResType(Integer ResType) {
		this.ResType = ResType;
	}

	public Date getResourceUpdated() {
		return this.resourceUpdated;
	}

	public void setResourceUpdated(Date resourceUpdated) {
		this.resourceUpdated = resourceUpdated;
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("Id: ").append(getId()).append(", ");
		sb.append("CivDeployed: ").append(getCivDeployed()).append(", ");
		sb.append("ResAvailable: ").append(getResAvailable()).append(", ");
		sb.append("ResType: ").append(getResType()).append(", ");
		sb.append("ResourceUpdated: ").append(getResourceUpdated()).append(", ");
		sb.append("PersonID: ").append(getPerson());
		return sb.toString();
	}

	@Override
	public int hashCode() {
		return toString().hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof CivResource)) {
			return false;
		}
		CivResource civ = (CivResource) obj;
		return (getPerson().equals(civ.getPerson()) && getResType().equals(civ.getResType()));
	}

}
